﻿// This Plugin spams burst of speed
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Xml.Linq;
using Styx.TreeSharp;
using CommonBehaviors.Actions;
using Styx;
using Styx.WoWInternals;
// HB Stuff
using Styx.Common;
using Styx.Common.Helpers;
using Styx.CommonBot;
using Styx.CommonBot.Inventory;
using Styx.Helpers;
using Styx.Plugins;
using Styx.WoWInternals.WoWObjects;

using System.Collections.Generic;

namespace BurstOfSpeed
{
    public class BurstOfSpeed : HBPlugin
    {
        #region Globals

        public override string Name { get { return "BurstOfSpeed"; } }
        public override string Author { get { return "Glen"; } }
        public override Version Version { get { return new Version(1, 0, 0, 1); } }
        public override bool WantButton { get { return false; } }
        private static LocalPlayer Me { get { return StyxWoW.Me; } }
        private int count = 0;
        private int stuckCount = 0;

        #endregion
        public override void Pulse()
        {
            if (!Me.Combat && Me.IsMoving && Me.IsAlive && !Me.IsGhost && !Me.IsOnTransport && !Me.OnTaxi && !Me.Stunned && !(Me.Mounted && Me.IsFlying) && !Me.IsCasting)
            {
                if (!Me.HasAura("Burst of Speed"))
                {
                    SpellManager.Cast("Burst of Speed");
                }
                count = 0;
                stuckCount = 0;
            }

            if (!Me.Combat && !Me.IsMoving && !(Me.Mounted && Me.IsFlying))
            {
                count++;
                //jump after 500 ticks
                if (count > 500)
                {
                    Styx.Helpers.KeyboardManager.PressKey((char)ConsoleKey.Spacebar);
                    Thread.Sleep(10);
                    Styx.Helpers.KeyboardManager.ReleaseKey((char)ConsoleKey.Spacebar);
                    stuckCount++;
                    count = 0;
                }
            }

            if (stuckCount >= 3)
            {
                TreeRoot.Stop();
                System.Threading.Thread.Sleep(10);
                TreeRoot.Start();
            }
        }
    }

}
